<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">	
<f:view contentType="text/html"> 		
    <h:head>
    	<title>KHS - Administrační rozhraní</title>
    	<style type="text/css">.adminPanel td { vertical-align: top; }</style>
    </h:head>
    <h:body bgcolor="white" >
	  		<p:growl id="growl"/> 
	  <h:form id="loginForm" style="font-size:12px;" >
	  	<h:panelGroup layout="block" style="margin: 0 auto;font-size:11px;">  
  			<p:panel header="KHS - Administrační rozhraní" >
				<h:panelGrid columns="2" styleClass="adminPanel" >	
					<p:panel header="Administrace týmu" rendered="#{editUserBean.logedIn}" style="min-width:950px;" >
						 <h:panelGrid columns="2">
								<p:panel header="Možnosti" style="min-width:210px;">	
									<h:panelGrid columns="1">								
										<p:commandButton value="Důležité k vyplnění"  actionListener="#{editUserBean. fillImportantMatches}" update="loginForm,:growl"/>
										<h:outputText value="Vyhledávání:"/>
										<p:selectOneMenu id="teamSelect" value="#{editUserBean.selectedTeamName}" style="width: 180px" >  
								             <f:selectItem  itemLabel="Vyberte tým" itemValue="" />  
								             <f:selectItems value="#{editUserBean.teamNameList}" />
								             <p:ajax  update="seasonSelect" listener="#{editUserBean.handleTeamChange}" />
					            		</p:selectOneMenu>
					            		<p:selectOneMenu id="seasonSelect" value="#{editUserBean.selectedSeasonName}" style="width: 180px" >  
								             <f:selectItem  itemLabel="Vyberte sezónu" itemValue="" />  
								             <f:selectItems value="#{editUserBean.seasonNameList}" />
					            		</p:selectOneMenu>
					            		<p:commandButton value="Potvrdit"  actionListener="#{editUserBean.fillMatchList}" action="admin.xhtml?faces-redirect=true" update="loginForm,:growl"/>
				            			<h:outputText value="Nastavení:"/>
				            			<p:commandButton value="Změnit heslo" oncomplete="seasonDialog.show()"/>
									</h:panelGrid>
				            	</p:panel>
				            	<p:panel header="Editace zápasů" style="min-width:700px;">		            			            	
				            		<p:dataTable sortBy="#{player.round}" id="playerTable" var="player" value="#{editUserBean.matchList}" rowKey="#{player.id}"  selection="#{editUserBean.selectedMatch}" emptyMessage="Žádné zápasy nenalezeny" selectionMode="single" tableStyle="min-width:300px;">
								        <f:facet name="header">
											<h:outputText value="Seznam zápasů k editaci"/>											
								        </f:facet>
								        <p:column headerText="Kolo" sortBy="#{player.round}" >  
								            <h:outputText value="#{player.round}" />  
								        </p:column>
								        <p:column headerText="Datum:" >  
								            <h:outputText value="#{player.datum}" />  
								        </p:column>
								        <p:column headerText="Čas:" >  
								            <h:outputText value="#{player.start}" />  
								        </p:column>
								        <p:column headerText="Domácí" >  
								            <h:outputText value="#{player.homeTeam.name}" />  
								        </p:column>
								        <p:column>  
								            <h:outputText value="#{player.homeTeamScore}" />  
								        </p:column>
								        <p:column>  
								            <h:outputText value="#{player.awayTeamScore}" />  
								        </p:column>
								        <p:column headerText="Hosté" >  
								            <h:outputText value="#{player.awayTeam.name}" />  
								        </p:column>
								        <f:facet name="footer">  
							         	    <p:commandButton  icon="ui-icon-document" value="upravit"  update=":form,:matchDetailDialog" oncomplete="DetailDialog.show()"/>           
					       				</f:facet> 
						  	        </p:dataTable>
				            	</p:panel>
				         </h:panelGrid>   			
					</p:panel>
					<p:panel>	
							<h:panelGrid columns="2" rendered="#{!editUserBean.logedIn}" >
								<h:outputText value="Přihlašovací jméno:" />
								<h:inputText value="#{editUserBean.username}" />
								<h:outputText value="Heslo:" />
								<h:inputSecret value="#{editUserBean.password}" />
								<p:commandButton ajax="false" value="Přihlásit" actionListener="#{editUserBean.login}" update="loginForm,:growl"  />
							</h:panelGrid>
							<h:panelGrid columns="2" style="font-size:12px" rendered="#{editUserBean.logedIn}" >
								<h:outputText value="Přihlášen jako " />
								<h:outputText value="#{editUserBean.loggedUser.username}" style="font-weight:bold;"/>
								<p:commandButton value="Odhlásit" actionListener="#{editUserBean.logout}" update="loginForm,:growl"  />
							</h:panelGrid>
					</p:panel>
				</h:panelGrid>	
			</p:panel>
	  	</h:panelGroup>
	  </h:form>
	  <p:dialog id="matchDetailDialog" header="Detail zápasu" widgetVar="DetailDialog" resizable="false" showEffect="clip" hideEffect="fold" style="font-size:11px;" position="10,10" height="300">
				<h:form>
					<h:panelGroup>
			        	<h:outputText value="#{editUserBean.selectedMatch.homeTeam.name}" /><h:outputText value="  " />
		        	 	<h:inputText value="#{editUserBean.selectedMatch.homeTeamScore}" readonly="true" style="width:20px" />
			       	 	<h:outputText value=" : " />
			       	 	<h:inputText value="#{editUserBean.selectedMatch.awayTeamScore}" readonly="true" style="width:20px"/><h:outputText value="  " />
			       	 	<h:outputText value="#{editUserBean.selectedMatch.awayTeam.name}" />	
			       	</h:panelGroup>			
					<h:panelGrid columns="4" cellpadding="4">   
				    	 	<h:outputText value="Kolo : " />
				   	 		<h:inputText value="#{editUserBean.selectedMatch.round}" readonly="true" style="width:20px"/>
				   	 		<h:panelGroup/><h:panelGroup/>
				 	 		<h:outputText value="Datum : " />
				 	 		<p:inputMask value="#{editUserBean.selectedMatch.datum}" readonly="true" mask="99.99.9999" style="width:70px"/>
				   	 		<h:outputText value="Čas : " />
				  	 		<p:inputMask value="#{editUserBean.selectedMatch.start}" readonly="true" mask="99:99" style="width:50px"/>
				   	 		<h:outputText value="Počet diváků : " />
				  	 		<h:inputText value="#{editUserBean.selectedMatch.pocetHracu}" style="width:100px" />
					</h:panelGrid>									     		
		        	 <h:panelGrid columns="2" cellpadding="4" >
		        	  	<p:panel header="Události : #{editUserBean.selectedMatch.homeTeam.name}" >
		      		  		 <h:panelGrid columns="2" cellpadding="4" width="250">
		    	   		  		<h:outputText value="Góly:" />
		   	    		  		<p:inputTextarea value="#{editUserBean.selectedMatch.domaciStrelci}" style="width:150px"  maxheight="80" autoResize="false" onfocus="this.value = '';"/> 
				       	  		<h:outputText value="Základní sestava (vzor):" />
				       	  		<h:outputText value="Marčišin – Tomášek, Plašil, Horák, Huňák – Schod (76. Novák), Voženílek, Stejskal, Hrubý J. (88. Lemfeld) Merganc (72. Kocourek), Václavek (87. Winkler) " />
				       	  		<h:outputText value="Základní sestava:" />
			        	  		<p:inputTextarea value="#{editUserBean.selectedMatch.domaciZaklSestava}" style="width:150px" rows="10" maxheight="150" autoResize="false" />
			        	  		<h:outputText value="Žluté karty (vzor):" />
				       	  		<h:outputText value="43. Horák, 56. Stejskal, 60. + 71. Voženílek " />
				       	  		<h:outputText value="Žluté karty:" />
				       	  		<p:inputTextarea value="#{editUserBean.selectedMatch.domaciZluteKarty}" style="width:150px"  maxheight="50" autoResize="false"/>
				       	  		<h:outputText value="Červené karty (vzor):" />
				       	  		<h:outputText value="71. Voženílek " />
				       	  		<h:outputText value="Červené karty:" />
				       	  		<p:inputTextarea value="#{editUserBean.selectedMatch.domaciCerveneKarty}" style="width:150px"  maxheight="30" autoResize="false"/>
				       	  		<h:outputText value="Jméno, funkce:" />
				       	  		<p:inputText value="#{editUserBean.selectedMatch.domaciJmeno}" style="width:150px"  maxheight="30" autoResize="false"/>
				       	  		<h:outputText value="Komentář:" />
				       	  		<p:inputTextarea value="#{editUserBean.selectedMatch.domaciKomentar}" style="width:150px"  maxheight="30" autoResize="false"/>
			     	  		</h:panelGrid>
			       	  	</p:panel>
			       	  	<p:panel header="Události : #{matchBean.selectedMatch.awayTeam.name}" >
			       	  		 <h:panelGrid columns="2" cellpadding="4" width="250">
			        	  		<h:outputText value="Góly:" />
			        	  		<p:inputTextarea value="#{editUserBean.selectedMatch.hosteStrelci}" style="width:150px" maxheight="80" autoResize="false"/> 
			        	  		<h:outputText value="Základní sestava (vzor):" />
				       	  		<h:outputText value="Marčišin – Tomášek, Plašil, Horák, Huňák – Schod (76. Novák), Voženílek, Stejskal, Hrubý J. (88. Lemfeld) Merganc (72. Kocourek), Václavek (87. Winkler) " />
				       	  		<h:outputText value="Základní sestava:" />
			        	  		<p:inputTextarea value="#{editUserBean.selectedMatch.hosteZaklSestava}" style="width:150px" rows="10" maxheight="100" autoResize="false" />
			        	  		<h:outputText value="Žluté karty (vzor):" />
				       	  		<h:outputText value="43. Horák, 56. Stejskal, 60. + 71. Voženílek " />
				       	  		<h:outputText value="Žluté karty:" />
			        	  		<p:inputTextarea value="#{editUserBean.selectedMatch.hosteZluteKarty}" style="width:150px" maxheight="40" autoResize="false"/>
			        	  		<h:outputText value="Červené karty (vzor):" />
				       	  		<h:outputText value="71. Voženílek " />
				       	  		<h:outputText value="Červené karty:" />
			        	  		<p:inputTextarea value="#{editUserBean.selectedMatch.hosteCerveneKarty}" style="width:150px" maxheight="30" autoResize="false"/>
			        	  		<h:outputText value="Jméno, funkce:" />
				       	  		<p:inputText value="#{editUserBean.selectedMatch.hosteJmeno}" style="width:150px"  maxheight="30" autoResize="false"/>
				       	  		<h:outputText value="Komentář:" />
			        	  		<p:inputTextarea value="#{editUserBean.selectedMatch.hosteKomentar}" style="width:150px" maxheight="40" autoResize="false"/>
			       	  		</h:panelGrid>							        	  	
		       	  	</p:panel>
		       	 </h:panelGrid>
			        	 <p:commandButton value="Uložit změny" actionListener="#{editUserBean.updateMatch}" update=":matchDetailDialog" oncomplete="DetailDialog.hide()"/>								
			</h:form>  
		</p:dialog> 
		<p:dialog id="dialog" header="Změnit heslo" widgetVar="seasonDialog" resizable="false"  
					              width="300" showEffect="clip" hideEffect="fold" position="10,10">  
						      	 <h:form>   
						      	    <h:panelGrid columns="2" cellpadding="4">
						      	       <h:outputText value="heslo" />    						      
							           <h:inputText value="#{editUserBean.loggedUser.password}" style="width:150px" required="true"/>      	 
						        	</h:panelGrid> 
						        	<p:commandButton value="Ulož nové heslo"  actionListener="#{editUserBean.updateUser}" oncomplete="seasonDialog.hide()"/> 
						        </h:form>	
		</p:dialog>     
	</h:body>
</f:view>	
</html>